package com.xros.demo.fileserver.controller;

import com.xros.demo.fileserver.domain.vo.ResultVo;
import com.xros.demo.fileserver.service.IFileService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Author: mzp
 * @Description: 文件控制器
 * @Date: 2024/3/27 10:51
 * @Version: 1.0
 */
@RestController
@RequestMapping("/file")
public class FileController {

    @Resource
    private IFileService fileService;

    /**
     * 上传单个文件接口
     * @param file
     * @return
     */
    @PostMapping
    public ResultVo<Boolean> uploadFile(@RequestParam MultipartFile file){
        return fileService.saveFile(file);
    }

    /**
     * 上传文件夹接口
     * @param file
     * @return
     */
    @PostMapping("/directory")
    public ResultVo<Object> uploadDirectory(@RequestParam MultipartFile[] file){

        return fileService.saveDirectory(file);

    }
}
